﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;

namespace BrainTechLLC.Silverlight.ClientApplication.Controls
{
    public partial class TopHUDControl : UserControl
    {
        public event EventHandler WantShowCharacter;
        public event EventHandler WantFindGameThings;
        public event EventHandler<ObjectEventArgs<LocationInt>> RequestEditGameLocation;

        public TopHUDControl()
        {
            // Required to initialize variables
            InitializeComponent();
        }

        public void OnWantShowCharacter()
        {
            if (WantShowCharacter != null)
                WantShowCharacter(this, new EventArgs());
        }

        public void OnWantFindGameThings()
        {
            if (WantFindGameThings != null)
                WantFindGameThings(this, new EventArgs());
        }

        private void btnShowCharacter_Click(object sender, RoutedEventArgs e)
        {
            OnWantShowCharacter();
        }

        private void btnFindGameThings_Click(object sender, RoutedEventArgs e)
        {
            OnWantFindGameThings();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
        }

        public void UpdateLocation(long id, LocationInt loc, long location)
        {
            if (id == DataAccess.CurrentlyPlayingId)
                Dispatcher.BeginInvoke(() => editLocationInt.LocationInt = loc);
        }

        private void EditLocationInt_RequestEditGameLocation(object sender, ObjectEventArgs<LocationInt> e)
        {
            if (RequestEditGameLocation != null)
                RequestEditGameLocation(sender, e);
        }
    }
}